#!/usr/bin/env python
#coding=utf-8
#File: settracer.py

import sys

def test(n):
    j = 0
    for i in range(n):
        j = j + i
    return n

def tracer(frame, event, arg):
    print event, frame.f_code.co_name, frame.f_lineno, "->", arg
    return tracer
    
# tracer is activated on the next call, return, or exception
sys.settrace(tracer)

# trace this function call
print test(1)

# disable tracer
sys.settrace(None)

# don't profile this call
print test(2)